import {
  AllUserListParams,
  UserItem,
  SearchByKeyWordsParams,
  SearchAreaParams,
  UploadFileParams,
  UploadApiResult,
  AddressParams,
} from './model';
import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode } from '/@/utils/http/axios/types';
import { getAppEnvConfig } from '/@/utils/env';
enum Api {
  AllUserList = '/greatPerformance/getUserList',
  SearchByKeyWords = '/mini/getSearchByKeyWords',
  GetAreaSite = '/mini/getAddressAfter',
  uploadVideo = '/mini/getLeaseHousesVideoUrl',
}

/**
 * @description: 查询所有用户列表
 */
export function AllUserListApi(params?: AllUserListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.AllUserList,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 查询详细地址
 */
export function SearchByKeyWordsApi(params: AddressParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.SearchByKeyWords,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 查询区域和城市地址
 */
export function getAreaSiteApi(params?: SearchAreaParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.GetAreaSite,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: Upload interface
 */
export function uploadVideoApi(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void
) {
  return defHttp.uploadFile<BasicFetchResult<any>>(
    {
      url: Api.uploadVideo,
      onUploadProgress,
    },
    params
  );
}
